using HKB.Common;
using System;
using System.Data;
using System.Web;
namespace HKB.Web
{
	public class ShopConfigBll
	{
		public string DataPath = "";
		private string InstallDir = AppSetings.Get("InstallDir");
		private string AppPrefix = AppSetings.Get("AppPrefix");
		public ShopConfigBll()
		{
			this.DataPath = HttpContext.Current.Server.MapPath("~/") + this.InstallDir + "App_Data/ShopConfig.config";
		}
		public DataTable GetConfig()
		{
			string text = this.AppPrefix + "HoWaveShopConfig";
			DataTable result;
			if (HttpContext.Current.Cache[text] != null)
			{
				result = (DataTable)HttpContext.Current.Cache[text];
			}
			else
			{
				DataSet dataSet = new DataSet();
				dataSet.ReadXml(this.DataPath);
				DataTable dataTable = dataSet.Tables[0];
				DataCache.SetCacheDepFile(text, dataTable, DataCache.shopconfigfile);
				result = dataTable;
			}
			return result;
		}
		public void UpdateConfig(string MemberType, string Showstandprice, string Allowedtourist, string ShowAction, string ShowTeam, string ShowPromote, string FahuoTiem, string PayWay, string VoidPay, string OnlinePay, string LeavePay, string ShowQQ, string ShowWW, string ShowBuyer1, string ShowSaler1, string ShowBuyer2, string ShowSaler2, string ShowBuyer3, string ShowSaler3, string TeamSet, string Team5Name, string Team4Name, string Team3Name, string Team2Name, string Team1Name, string SaleDay, string ShowShop, string ShowScore, string UserTryClothesModel, string LotteryJifenEveryTime)
		{
			DataSet dataSet = new DataSet();
			dataSet.ReadXml(this.DataPath);
			DataTable dataTable = dataSet.Tables[0];
			DataRow dataRow = dataTable.Rows[0];
			dataRow["Member"] = MemberType;
			dataRow["Showstandprice"] = Showstandprice;
			dataRow["Allowedtourist"] = Allowedtourist;
			dataRow["ShowAction"] = ShowAction;
			dataRow["ShowTeam"] = ShowTeam;
			dataRow["ShowPromote"] = ShowPromote;
			dataRow["ShowScore"] = ShowScore;
			dataRow["FahuoTiem"] = FahuoTiem;
			dataRow["PayWay"] = PayWay;
			dataRow["VoidPay"] = VoidPay;
			dataRow["OnlinePay"] = OnlinePay;
			dataRow["LeavePay"] = LeavePay;
			dataRow["ShowQQ"] = ShowQQ;
			dataRow["ShowWW"] = ShowWW;
			dataRow["ShowBuyer1"] = ShowBuyer1;
			dataRow["ShowSaler1"] = ShowSaler1;
			dataRow["ShowBuyer2"] = ShowBuyer2;
			dataRow["ShowSaler2"] = ShowSaler2;
			dataRow["ShowBuyer3"] = ShowBuyer3;
			dataRow["ShowSaler3"] = ShowSaler3;
			dataRow["TeamSet"] = TeamSet;
			dataRow["Team5Name"] = Team5Name;
			dataRow["Team4Name"] = Team4Name;
			dataRow["Team3Name"] = Team3Name;
			dataRow["Team2Name"] = Team2Name;
			dataRow["Team1Name"] = Team1Name;
			dataRow["SaleDay"] = SaleDay;
			dataRow["ShowShop"] = ShowShop;
			dataRow["UserTryClothesModel"] = UserTryClothesModel;
			dataRow["LotteryJifenEveryTime"] = LotteryJifenEveryTime;
			try
			{
				dataSet.WriteXml(this.DataPath);
			}
			catch
			{
				throw new Exception("文件 /App_Data/ShopConfig.config 没有写入权限！");
			}
			HttpContext.Current.Cache.Remove(this.AppPrefix + "HoWaveShopConfig");
		}
	}
}
